package com.beerandjesus.sportofkings.handicapper.factory.brisnet.singlefile;

import com.beerandjesus.sportofkings.handicapper.model.brisnet.singlefile.Horse;
import com.beerandjesus.sportofkings.handicapper.model.brisnet.singlefile.HorseImpl;

public class HorseFactoryImpl extends AbstractObjectFactoryImpl implements HorseFactory {
	
	private PedigreeFactory pedigreeFactory;
	private PerformanceRecordFactory performanceRecordFactory;
	private TrainerJockeyOwnerFactory trainerJockeyOwnerFactory;
	private WorkoutFactory workoutFactory;
	private PastPerformanceFactory pastPerformanceFactory;
	
	/* (non-Javadoc)
	 * @see com.beerandjesus.sportofkings.handicapper.factory.brisnet.singlefile.HorseFactory#getHorse(java.lang.String)
	 */
	public Horse getHorse(String dataLine) {
		String[] values = getValues(dataLine);
		
		return getHorse(values);
	}

	public Horse getHorse(String[] values) {
		HorseImpl h = new HorseImpl();
		
		h.setProgramNumber(val(values,43));
		h.setEntry(val(values,5));
		h.setName(val(values,45));
		h.setMorningLineOdds(val(values,44));
		h.setBirthYear(val(values,46));
		h.setFoalingMonth(val(values,47));
		h.setSex(val(values,49));
		h.setColor(val(values,50));
		h.setWeight(val(values,51));
		h.setSireName(val(values,52));
        h.setDamSireName(val(values,55));
        h.setAuctionPrice(val(values,1222));
		h.setCurrentStudFee(val(values,1177));
		h.setMainTrackOnlyOrAE(val(values,41));
		h.setPostPosition(val(values,4));
		h.setProgramPostPosition(val(values,58));
		h.setMedication(u.getMedication(val(values,62)));
		h.setEquipmentChange(u.getEquipmentChange(val(values,64)));
		h.setBrisRunStyle(val(values,210));
		h.setQuirinSpeedPoints(val(values,211));
		h.setDaysSinceLastRace(val(values,224));
		h.setLifeStartsAllWeather(val(values,231));
		h.setLifeWinsAllWeather(val(values,232));
		h.setLifePlaceAllWeather(val(values,233));
		h.setLifeShowAllWeather(val(values,234));
		h.setLifeEarningsAllWeather(val(values,235));
		h.setBestBrisSpeedAllWeather(val(values,236));
		h.setPrimePowerRating(val(values,251));
		h.setBestBrisSpeedLife(val(values,1328));
		h.setBestBrisSpeedRecentYear(val(values,1329));
		h.setBestBrisSpeed2ndRecentYear(val(values,1330));
		h.setBestBrisSpeedThisTrack(val(values,1331));

		h.setNumStartsDirt(val(values,1332));
		h.setNumWinsDirt(val(values,1333));
		h.setNumPlacesDirt(val(values,1334));
		h.setNumShowsDirt(val(values,1335));
		h.setEarningsDirt(val(values,1336));
		
		
		h.setPedigree(getPedigreeFactory().getPedigree(values));
		h.setPerformanceRecord(getPerformanceRecordFactory().getPerformanceRecord(values));
		h.setTrainerJockeyOwner(getTrainerJockeyOwnerFactory().getTrainerJockeyOwner(values));
		h.setWorkouts(getWorkoutFactory().getWorkouts(values));
		h.setPastPerformances(getPastPerformanceFactory().getPastPerformances(values));
		return h;
	}

	public PedigreeFactory getPedigreeFactory() {
		return pedigreeFactory;
	}

	public void setPedigreeFactory(PedigreeFactory pedigreeFactory) {
		this.pedigreeFactory = pedigreeFactory;
	}

	public PerformanceRecordFactory getPerformanceRecordFactory() {
		return performanceRecordFactory;
	}

	public void setPerformanceRecordFactory(
			PerformanceRecordFactory performanceRecordFactory) {
		this.performanceRecordFactory = performanceRecordFactory;
	}

	public TrainerJockeyOwnerFactory getTrainerJockeyOwnerFactory() {
		return trainerJockeyOwnerFactory;
	}

	public void setTrainerJockeyOwnerFactory(
			TrainerJockeyOwnerFactory trainerJockeyOwnerFactory) {
		this.trainerJockeyOwnerFactory = trainerJockeyOwnerFactory;
	}

	public WorkoutFactory getWorkoutFactory() {
		return workoutFactory;
	}

	public void setWorkoutFactory(WorkoutFactory workoutFactory) {
		this.workoutFactory = workoutFactory;
	}

	public PastPerformanceFactory getPastPerformanceFactory() {
		return pastPerformanceFactory;
	}

	public void setPastPerformanceFactory(
			PastPerformanceFactory pastPerformanceFactory) {
		this.pastPerformanceFactory = pastPerformanceFactory;
	}

}
